package com.Object01.homework.homework05;

public class Person {
    private String name;
    private String sex;
    private int age;

    public Person(String name, String sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


    public String toString() {
        return "姓名：" + name + '\n' +
                "年龄" + age +'\n'+
                "性别：" + sex + '\n'
                ;
    }

    public void test(Person person) {
        if (person instanceof Student) {
            ((Student) person).study();
        }
        if (person instanceof Teacher) {
            ((Teacher) person).teach();
        }
    }
}
